<template>
    <el-dialog v-model="open" title="添加dao成员" width="510px">
        <el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
            <el-form-item label="地址" prop="address">
                <el-input v-model="formData.address" placeholder="请输入地址" />
            </el-form-item>
            <el-form-item prop="amount4">
                <el-radio-group v-model="formData.status">
                    <el-radio :label="0" size="large">Dao常委</el-radio>
                    <el-radio :label="1" size="large">Dao委员</el-radio>
                </el-radio-group>
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button type="primary" :loading="loading" @click="onSubmit('formData')">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script setup>
import { reactive, ref, defineExpose, defineEmits } from "vue";
import { addDao } from "@/api";
import { ElMessageBox, ElMessage } from "element-plus";
const emit = defineEmits(["onSubmit"]);
const formRef = ref();
const open = ref(false);
const formData = reactive({
    address: "",
    status: 0,
});
const formRules = {
    address: [{ required: true, message: "请输入地址", trigger: "change" }],
};
const loading = ref(false);
const onSubmit = async () => {
    try {
        const a = await formRef.value.validate().catch(() => null);
        if (!a) return;
        open.value = false;
        const res = await addDao(formData);
        if (res.data.code == 20) {
            ElMessage({
                message: "成功",
                type: "success",
            });
        }
        emit("onSubmit");
    } catch (error) {}
};
const show = (row) => {
    open.value = true;
    formData.address = "";
    formData.status = 0;
};
defineExpose({
    show,
});
</script>
<style lang="scss" scoped>
.right {
    overflow: auto;
}

.el-pagination {
    padding: 15px;
    float: right;
}
</style>